package com.todo.biz.application.frontend.service.impl;

import com.todo.biz.application.convert.DictConvert;
import com.todo.biz.application.entity.bo.BaseDictBO;
import com.todo.biz.application.frontend.service.DictAggService;
import com.todo.biz.application.service.BaseDictService;
import com.todo.biz.iface.frontend.request.QueryDictDetailParam;
import com.todo.biz.iface.frontend.response.DictDetailVO;
import com.todo.common.common.enums.BizErrorCodeEnum;
import com.todo.common.common.exception.BizException;
import com.todo.common.common.entity.response.BizResponse;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/12/9 19:32
 * @description
 */
@Slf4j
@Service("dictAggService")
public class DictAggServiceImpl implements DictAggService {

    @Resource
    private BaseDictService baseDictService;

    @Override
    public BizResponse<DictDetailVO> queryDictDetail(QueryDictDetailParam param) {
        if (param == null || !param.baseCheck()){
            throw new BizException(BizErrorCodeEnum.OPERATION_FAILED);
        }
        BaseDictBO baseDictBO = baseDictService.queryBaseDictByBizCodeAndSceneCode(param.getBizCode(), param.getSceneCode());
        return BizResponse.success(DictConvert.convertToDictDetailVO(baseDictBO));
    }
}
